package cn.weekimwee.firstlineofcodeforkotlin.unit6

import android.os.Bundle
import android.view.View
import cn.weekimwee.firstlineofcodeforkotlin.BaseActivity
import cn.weekimwee.firstlineofcodeforkotlin.R
import kotlinx.android.synthetic.main.activity_unit6.*
import org.jetbrains.anko.startActivity

class Unit6Activity : BaseActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_unit6)
        saveFile.setOnClickListener { it.onClick() }
        shared.setOnClickListener { it.onClick() }
        create.setOnClickListener { it.onClick() }
        litePalButton.setOnClickListener { it.onClick() }
    }

    private fun View.onClick() {
        when (this.id) {
            R.id.saveFile -> {
                startActivity<SaveFileActivity>()
            }
            R.id.shared -> {
                startActivity<SharedPreferencesActivity>()
            }
            R.id.create -> {
                startActivity<SQLiteActivity>()
            }
            R.id.litePalButton->{
                startActivity<LitePalActivity>()
            }
        }
    }
}
